import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_news/common/entity/entitys.dart';
import 'package:flutter_news/common/router/AuthGuard.dart';
import 'package:flutter_news/pages/application/application.dart';
import 'package:flutter_news/pages/detail/details.dart';
import 'package:flutter_news/pages/index/index.dart';
import 'package:flutter_news/pages/sign_in/sign_in.dart';
import 'package:flutter_news/pages/sign_up/sign_up.dart';
import 'package:flutter_news/pages/welcome/welcome.dart';

part 'router.gr.dart';

Widget zoomInTransition(BuildContext context, Animation<double> animation,
    Animation<double> secondaryAnimation, Widget child) {
  // you get an animation object and a widget
  // make your own transition
  return ScaleTransition(scale: animation, child: child);
}

@AutoRouterConfig()
class AppRouter extends _$AppRouter {
  @override
  List<AutoRoute> get routes => [
        /// routes go here
        // AutoRoute(
        //   page: IndexRoute.page,
        //   initial: true, // 这里为 true，表示默认路由
        // ),
        //
        // AutoRoute(
        //   page: DetailsRoute.page,
        // ),

        CustomRoute(
            page: IndexRoute.page,
            transitionsBuilder: zoomInTransition,
            initial: true),

        CustomRoute(
          page: DetailsRoute.page,
          transitionsBuilder: zoomInTransition,
          guards: [AuthGuard()],
        ),

        CustomRoute(
          page: SignInRoute.page,
          transitionsBuilder: zoomInTransition,
        ),

        CustomRoute(
          page: SignUpRoute.page,
          transitionsBuilder: zoomInTransition,
        ),

        CustomRoute(
          page: WelcomeRoute.page,
          transitionsBuilder: zoomInTransition,
        ),

        CustomRoute(
          page: ApplicationRoute.page,
          transitionsBuilder: zoomInTransition,
        ),
      ];
}
